/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amuthu.indicator;

import org.amuthu.DataStore;
import org.amuthu.TalibMgr;

/**
 *
 * @author prabhu
 */
public class Adx extends Indicator
{
   private int period;

   /**
    *
    * @param dataStore
    * @param period
    * @param startOffset
    */
   public Adx(DataStore dataStore,
              int period,
              int startOffset)
   {
      super(dataStore, startOffset);
      this.period = period;
   }

   /**
    *
    * @return
    */
   @Override
   public double calculate()
   {
      int lastIdx = getLastIndex();

      TalibMgr.getTalib().adx(lastIdx,
                              lastIdx,
                              getDataStore().getHigh(),
                              getDataStore().getLow(),
                              getDataStore().getClose(),
                              period,
                              TalibMgr.getOutBeginIdx(),
                              TalibMgr.getOutNbElement(), getResultArray());

      return getResultValue();
   }

   @Override
   public int getDayDependency()
   {
        return  TalibMgr.getTalib().adxLookback(period) + startOffset;
   }

}
